package org.wenhuayuan.project.common.uicomp;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public abstract class HiBaseFragment extends Fragment {
    // fragment-根布局
    protected View layoutView;

    @LayoutRes
    public abstract int getLayoutRes();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return layoutView = inflater.inflate(getLayoutRes(), container, false);
    }

    public boolean isAlive() {
        //踩坑：所以在更新之前要判断页面是否还存在
        if (null == getActivity() || isRemoving() || isDetached()) {
            return false;
        }
        return true;
    }
}
